<?php
/**
 *文件上传类
 * User: woddp
 * Date: 2017/3/18
 * Time: 18:29
 */

namespace File\Controller;

use Org\File\File;
use Think\Controller;

class FileController extends Controller{


    public function upload(){
        if(IS_POST){
          $data=I('post.');
            if(empty($data['filePath'])){
                return  $this->ajaxReturn(['status' => true, 'msg' =>'上传路径不存在']);
            }

                $upload = new \Think\Upload();// 实例化上传类
//                $upload->maxSize   =     3145728 ;// 设置附件上传大小
                $upload->saveName = '';
//                $upload->exts    =    array('jpg', 'gif', 'png', 'jpeg');// 设置附件上传类型
                $upload->rootPath  =     $data['filePath'].'/'; // 设置附件上传根目录
                $upload->savePath  =     ''; // 设置附件上传（子）目录
                $upload->subName  =     ''; // 设置附件上传（子）目录
                // 上传文件
                $info   =   $upload->upload();
                if(!$info) {// 上传错误提示错误信息
                      return $this->ajaxReturn(['status' => false, 'msg' =>$upload->getError()]);
                }else{// 上传成功
//                    $this->success('上传成功！');
                     return $this->ajaxReturn(['status' => true, 'msg' =>'上传成功']);
                }


        }else{
            $file=I('get.name');
            $file1=new File();
            $file1->detect_encoding($file);
        }

    }

}